#include <iostream>
#include <string>
#include <sstream>
using namespace std;
const int N = 100005;
int n, x, y, S[N], n1, n2;
char c;

int getf (int a) {
	if (a == S[a]) {
		return a;
	}
	return S[a] = getf (S[a]);
}

void merge (int a, int b) {
	int v = getf(a);
    int u = getf(b);
    if (v == u) {
    	return;
    }
    S[u] = v;
    S[a] = v;
}

stringstream ss;
string s;

int main() {
	while (!cin.eof()) {
		getline(cin, s);
		ss.clear();
		ss.str(s);
		ss >> n;
		if (n == 0) continue;
		n1 = 0;
		n2 = 0;
		for (int i = 1; i <= n; i++) {
			S[i] = i;
		}
		while (!cin.eof()) {
			getline(cin, s);
			if (s.size() == 0) break;
			ss.clear();
			ss.str(s);
			ss >> c >> x >> y;
			if (c == 'c') {
				merge(x, y);
			} else {
				if (getf(x) == getf(y)) {
					n1++;
					//cout << "n1:" << x << " " << y << " " << n1 << endl;
				} else {
					n2++;
					//cout << "n2:" << x << " " << y << " " << n2 << endl;
				}
			}
		}
		cout << n1 << "," << n2 << endl;
	}
	return 0;
}